﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Innoapps.FileTransfer.Models
{

    

    public class Transfer
    {

        #region Variables
        private Guid id = Guid.NewGuid();
        private string action;
        private Adapters.Receive.Base receiveAdapter;
        private Adapters.Send.Base sendAdapter;
        private List<ActionResult> actionResults = new List<ActionResult>();
        private DateTime nextActionScheduled = DateTime.Now;
        private bool inProcess;
        #endregion

        #region Properties

        [XmlAttribute("Id")]
        public Guid Id {  get { return id; } set { id = value; } }
        [XmlAttribute("NextAction")]
        public string NextAction {  get { return action; } set { action = value; } } 
        [XmlElement("Receive")]
        public Adapters.Receive.Base Receive { get { return receiveAdapter; } set { receiveAdapter = value; receiveAdapter.transfer = this; } }
        [XmlElement("Send")]
        public Adapters.Send.Base Send { get { return sendAdapter; } set { sendAdapter = value; sendAdapter.transfer = this; } }
        [XmlElement("ActionResults")]
        public List<ActionResult> ActionResults
        {
            get { return actionResults; }
            set { actionResults = value; }
        }
        [XmlAttribute("NextAction_Scheduled")]
        public DateTime NextAction_Scheduled { get { return nextActionScheduled; } set { nextActionScheduled = value; } }
        [XmlIgnore()]
        public bool InProcess {  get { return inProcess; } set { inProcess = value; } }

        [XmlIgnore()]
        public bool IsNew {  get { return (ActionResults.Last().Action == "Innoapps.FileTransfer.Providers.State.Create"); } }

        [XmlIgnore()]
        public Stream Stream { get; set; }

        #endregion

    }
}
